package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Repository
public class UserDao {
    /*
    Value("")注解：依赖注入注解，否则会报错
    添加位置：
      1.添加在属性上
      2.添加在set方法上

      @Autowired 除此之外还可以添加在构造方法上
     */
    @Value("jdbc:mysql://localhost:3306/tedu")
    private String url;
    @Value("root")
    private String username;
    //    @Value("871762599")
    private String password;

    @Value("871762599")
    public void setPassword(String password) {
        this.password = password;
    }


    @Override
    public String toString() {
        return "UserDao{" +
                "url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}

/*
@Component  //不分层
@Controller //数据控制层
@Service    //业务逻辑层
@Repository //数据访问层
 */